import requests


class TestApi:
    def test(self):
        # req = requests.get("https://selectcar.yiche.com/selectcarforapp?mid=7&s=4&page=1&pagesize=20&cityId=405")
        parm = {"mid": 7, "s": 4, "page": 1, "pagesize": 20, "cityId": 405}
        req = requests.get("https://selectcar.yiche.com/selectcarforapp", params=parm)
        #  打印url地址
        print(req.url)
        #  打印status_code
        print(req.status_code)
        #  打印编码格式
        print(req.encoding)
        #  头部信息
        print(req.headers)
        #  文本值
        print(req.text)
        #  获取节点的值
        req_json = req.json()
        car_name = req_json['data']['resList'][8]['tags'][0]['value']
        print(car_name)
        #  前缀后缀,返回的是bool类型
        print(req.url.startswith("http"))
        print(req.url.endswith("405"))
